package com.cqan.tuan.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.cqan.entity.pk.LongEntity;

/**
 * 
 * 商品实体类
 * 
 * 2012-12-12下午8:07:37 Created by @author slaton
 */
@Entity
// 表名与类名不相同时重新定义表名.
@Table(name = "TBL_GOODS")
// 默认的缓存策略.
@SuppressWarnings("serial")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Goods extends LongEntity implements BaseEntity {
	
	private String url;
	
	private String wapUrl;

	private String webSite;
	
	private Long webSiteId;

	private String cityName;

	private String cityId;

	// 网站商品ID
	private String webSiteGoodId;

	private String title;

	// 分类
	private String cate;

	private String description;

	// 原价格
	private float originalPrice;

	// 现价
	private float price;

	// 折扣
	private float rebate;

	// 已售商品数量
	private Integer salesNum = 0;

	// 开始时间
	private long startTime;

	// 结束时间
	private long endTime;

	// 销售范围
	private String areaRange;

	// 地址
	private String address;

	// 纬度
	private String latitude;

	// 经度
	private String longitude;
	
	//商品名称
	private String name;
	
	//商家名称
	private String seller;
	
	//电话
	private String phone;
	
	//大图
	private String image;
	//小图
	private String smallImage;
	//状态 true:正常，false:结束
	private boolean state;
	
	private List<Shop> shops;
	
	
	public Long getWebSiteId() {
		return webSiteId;
	}

	public void setWebSiteId(Long webSiteId) {
		this.webSiteId = webSiteId;
	}

	public boolean isState() {
		return state;
	}

	public void setState(boolean state) {
		this.state = state;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}


	public String getWapUrl() {
		return wapUrl;
	}


	public void setWapUrl(String wapUrl) {
		this.wapUrl = wapUrl;
	}


	public String getWebSite() {
		return webSite;
	}


	public void setWebSite(String webSite) {
		this.webSite = webSite;
	}


	public String getCityName() {
		return cityName;
	}


	public void setCityName(String cityName) {
		this.cityName = cityName;
	}


	public String getCityId() {
		return cityId;
	}


	public void setCityId(String cityId) {
		this.cityId = cityId;
	}


	public String getWebSiteGoodId() {
		return webSiteGoodId;
	}


	public void setWebSiteGoodId(String webSiteGoodId) {
		this.webSiteGoodId = webSiteGoodId;
	}


	public String getTitle() {
		return title;
	}


	public void setTitle(String title) {
		this.title = title;
	}


	public String getCate() {
		return cate;
	}


	public void setCate(String cate) {
		this.cate = cate;
	}


	public String getDescription() {
		return description;
	}


	public void setDescription(String description) {
		this.description = description;
	}


	public float getOriginalPrice() {
		return originalPrice;
	}


	public void setOriginalPrice(float originalPrice) {
		this.originalPrice = originalPrice;
	}


	public float getPrice() {
		return price;
	}


	public void setPrice(float price) {
		this.price = price;
	}


	public float getRebate() {
		return rebate;
	}


	public void setRebate(float rebate) {
		this.rebate = rebate;
	}


	public Integer getSalesNum() {
		return salesNum;
	}


	public void setSalesNum(Integer salesNum) {
		this.salesNum = salesNum;
	}


	public long getStartTime() {
		return startTime;
	}


	public void setStartTime(long startTime) {
		this.startTime = startTime;
	}


	public long getEndTime() {
		return endTime;
	}


	public void setEndTime(long endTime) {
		this.endTime = endTime;
	}


	public String getAreaRange() {
		return areaRange;
	}


	public void setAreaRange(String areaRange) {
		this.areaRange = areaRange;
	}


	public String getAddress() {
		return address;
	}


	public void setAddress(String address) {
		this.address = address;
	}


	public String getLatitude() {
		return latitude;
	}


	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}


	public String getLongitude() {
		return longitude;
	}


	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public String getSeller() {
		return seller;
	}


	public void setSeller(String seller) {
		this.seller = seller;
	}


	public String getPhone() {
		return phone;
	}


	public void setPhone(String phone) {
		this.phone = phone;
	}


	 @ManyToMany(cascade=CascadeType.ALL)
	 @JoinTable(name = "TBL_SHOP_GOODS", 
	            joinColumns = { @JoinColumn(name = "good_id", referencedColumnName = "id") },
	            inverseJoinColumns = { @JoinColumn(name = "shop_id", referencedColumnName = "id")})
	 @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<Shop> getShops() {
		return shops;
	}


	public void setShops(List<Shop> shops) {
		this.shops = shops;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getSmallImage() {
		return smallImage;
	}

	public void setSmallImage(String smallImage) {
		this.smallImage = smallImage;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
	

}
